SMODS.DynaTextEffect#
This class is used to add effects to text descriptions and other DynaText objects
Required parameters:
key
Optional parameters:
prefix_config, dependencies(reference)
API methods#
func(dynatext, index, letter)Used to modify each letter, where
indexis the position of the letter in the string anddynatextis the DynaText object
draw_letter(dynatext, index, letter)Runs when the letter is being drawn to the screen, where
indexis the position of the letter in the string anddynatextis the DynaText object
draw_shadow(dynatext, index, letter)Runs when the letter’s shadow is being drawn to the screen, where
indexis the position of the letter in the string anddynatextis the DynaText object
draw_override(dynatext)Replaces the
drawfunction of thedynatextobject entirely
Letters#
Each DynaText letter is a table that has the following properties
letter(love.graphics.Text) - A replaceable text object that will get drawnchar(string) - The string character this letter representspop_in(number) - Determines how the letter gradually pops inr(number) - Rotation of the letter in radians, defaults to 0scale(number) - Scale of the letter with the normal size being 1dims({x: integer, y: integer}) - A table with x and y as letter’s dimension. in this case it does NOT modify the size that it is drawn. it instead modifies how far apart each letter areoffset({x: integer, y: integer}) - A table with x and y to specify the letter’s offset from the main dynatext alignmentcolour(table) - The letter’s colour. Ignored ifprefixorsuffixare setprefix(table) - The letter’s colour if it’s part of the DynaText’sprefix.suffix(table) - The letter’s colour if it’s part of the DynaText’ssuffix. Ignored ifprefixis set
Applying effects to text#
For your effect to show up in game, you can assign it to formatted text using the style modifier code E: Example:
-- Effect code
-- Rotates letters a different amount based on position
SMODS.DynaTextEffect {
key = "rotating",
func = function (self, index, letter)
letter.r = math.sin((G.TIMERS.REAL + index)*1.9443) * math.pi / 7
end
}
-- In your localization file:
j_modprefix_example = {
name = "{E:modprefix_rotating}Example",
text = {
{
"{C:chips,E:modprefix_rotating}+#1#{} Chips",
},
},
},